package com.xingfudazi.app.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xingfudazi.common.utils.IdGen;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 * 交易表
 * </p>
 *
 * @author Yu JiaMing
 * @since 2023-11-13
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "AppTrade对象", description = "交易表")
public class AppTrade implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    @ApiModelProperty(value = "订单编号")
    private String orderNo;

    @ApiModelProperty(value = "交易类型 （报名、报名退款、转账、系统添加)")
    private String type;

    @ApiModelProperty(value = "钱包名字")
    private String walletName;

    @ApiModelProperty(value = "钱包id")
    private String walletId;

    @ApiModelProperty(value = "币种（茶能、积分、人民币）")
    private String currency;

    @ApiModelProperty(value = "价格")
    private String price;

    @ApiModelProperty(value = "交易前额度")
    private String bValue;

    @ApiModelProperty(value = "交易后额度")
    private String aValue;

    @ApiModelProperty(value = "创建者")
    @TableField(fill = FieldFill.INSERT, value = "create_by")
    private String createBy;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT, value = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "更新者")
    @TableField(fill = FieldFill.UPDATE, value = "update_by")
    private String updateBy;

    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.UPDATE, value = "update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "备注")
    private String remark;

    public static String getNextActOrderNo() {
        return "ACT" + IdGen.nextLongId() + System.currentTimeMillis();
    }

    public static String getNextSysOrderNo() {
        return "SYS" + IdGen.nextLongId() + System.currentTimeMillis();
    }

    public static String getNextTransferOrderNo() {
        return "TRA" + IdGen.nextLongId() + System.currentTimeMillis();
    }
}
